package javolution.context;

/* loaded from: classes2.dex */
public abstract class ArrayFactory<T> {
    public static final ArrayFactory<boolean[]> BOOLEANS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.1
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new boolean[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((boolean[]) obj).length);
        }
    };
    public static final ArrayFactory<byte[]> BYTES_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.2
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new byte[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((byte[]) obj).length);
        }
    };
    public static final ArrayFactory<char[]> CHARS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.3
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new char[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((char[]) obj).length);
        }
    };
    public static final ArrayFactory<short[]> SHORTS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.4
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new short[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((short[]) obj).length);
        }
    };
    public static final ArrayFactory<int[]> INTS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.5
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new int[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((int[]) obj).length);
        }
    };
    public static final ArrayFactory<long[]> LONGS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.6
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new long[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((long[]) obj).length);
        }
    };
    public static final ArrayFactory<float[]> FLOATS_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.7
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new float[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((float[]) obj).length);
        }
    };
    public static final ArrayFactory<double[]> DOUBLES_FACTORY = new ArrayFactory() { // from class: javolution.context.ArrayFactory.8
        @Override // javolution.context.ArrayFactory
        protected Object create(int i) {
            return new double[i];
        }

        @Override // javolution.context.ArrayFactory
        public void recycle(Object obj) {
            recycle(obj, ((double[]) obj).length);
        }
    };
    private final ObjectFactory _factory4 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.9
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(4);
        }
    };
    private final ObjectFactory _factory8 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.10
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(8);
        }
    };
    private final ObjectFactory _factory16 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.11
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(16);
        }
    };
    private final ObjectFactory _factory32 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.12
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(32);
        }
    };
    private final ObjectFactory _factory64 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.13
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(64);
        }
    };
    private final ObjectFactory _factory128 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.14
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(128);
        }
    };
    private final ObjectFactory _factory256 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.15
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(256);
        }
    };
    private final ObjectFactory _factory512 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.16
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(512);
        }
    };
    private final ObjectFactory _factory1024 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.17
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(1024);
        }
    };
    private final ObjectFactory _factory2048 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.18
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(2048);
        }
    };
    private final ObjectFactory _factory4096 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.19
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(4096);
        }
    };
    private final ObjectFactory _factory8192 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.20
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(8192);
        }
    };
    private final ObjectFactory _factory16384 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.21
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(16384);
        }
    };
    private final ObjectFactory _factory32768 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.22
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(32768);
        }
    };
    private final ObjectFactory _factory65536 = new ObjectFactory() { // from class: javolution.context.ArrayFactory.23
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // javolution.context.ObjectFactory
        public Object create() {
            return ArrayFactory.this.create(65536);
        }
    };

    private final T largeArray(int i) {
        ObjectFactory objectFactory;
        if (i <= 8) {
            objectFactory = this._factory8;
        } else if (i <= 16) {
            objectFactory = this._factory16;
        } else if (i <= 32) {
            objectFactory = this._factory32;
        } else if (i <= 64) {
            objectFactory = this._factory64;
        } else if (i <= 128) {
            objectFactory = this._factory128;
        } else if (i <= 256) {
            objectFactory = this._factory256;
        } else if (i <= 512) {
            objectFactory = this._factory512;
        } else if (i <= 1024) {
            objectFactory = this._factory1024;
        } else if (i <= 2048) {
            objectFactory = this._factory2048;
        } else if (i <= 4096) {
            objectFactory = this._factory4096;
        } else if (i <= 8192) {
            objectFactory = this._factory8192;
        } else if (i <= 16384) {
            objectFactory = this._factory16384;
        } else if (i <= 32768) {
            objectFactory = this._factory32768;
        } else if (i > 65536) {
            return create(i);
        } else {
            objectFactory = this._factory65536;
        }
        return (T) objectFactory.object();
    }

    public final T array(int i) {
        return i <= 4 ? (T) this._factory4.object() : largeArray(i);
    }

    protected abstract T create(int i);

    public void recycle(T t) {
        recycle(t, ((Object[]) t).length);
    }

    final void recycle(Object obj, int i) {
        ObjectFactory objectFactory;
        if (i <= 4) {
            objectFactory = this._factory4;
        } else if (i <= 8) {
            objectFactory = this._factory8;
        } else if (i <= 16) {
            objectFactory = this._factory16;
        } else if (i <= 32) {
            objectFactory = this._factory32;
        } else if (i <= 64) {
            objectFactory = this._factory64;
        } else if (i <= 128) {
            objectFactory = this._factory128;
        } else if (i <= 256) {
            objectFactory = this._factory256;
        } else if (i <= 512) {
            objectFactory = this._factory512;
        } else if (i <= 1024) {
            objectFactory = this._factory1024;
        } else if (i <= 2048) {
            objectFactory = this._factory2048;
        } else if (i <= 4096) {
            objectFactory = this._factory4096;
        } else if (i <= 8192) {
            objectFactory = this._factory8192;
        } else if (i <= 16384) {
            objectFactory = this._factory16384;
        } else if (i <= 32768) {
            objectFactory = this._factory32768;
        } else if (i > 65536) {
            return;
        } else {
            objectFactory = this._factory65536;
        }
        objectFactory.recycle(obj);
    }
}
